/**
 * Created by Administrator on 2018/7/27.
 */
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Switch, Route ,Link ,Redirect} from 'react-router-dom';

//布局安排
import Layout   from 'component/layout/index.jsx';
// 页面
import Home     from 'page/home/index.jsx';
//登录页面
import Login    from 'page/login/index.jsx';
//用户管理界面
import UserList from 'page/user/index.jsx'
//错误页面
import ErrorPage from 'page/error/index.jsx';

class App extends React.Component{
    render(){
        let LayoutRouter = (
            <Layout>
                <Switch>
                    <Route exact path="/" component={Home}/>
                    <Route exact path="/product" component={Home}/>
                    <Route exact path="/product-category" component={Home}/>
                    <Route path="/user/index" component={UserList}/>
                    <Redirect exact from="/user" to="/user/index"/>
                    <Route component={ErrorPage}/>
                </Switch>
            </Layout>
        );
        return (
            <div>
                <Router>
                    <Switch>
                        <Route path="/login" component={Login}/>
                        <Route path="/" render={ props => LayoutRouter }/>
                    </Switch>

                </Router>
            </div>
        )
    }
}
ReactDOM.render(
    <App/>,
    document.getElementById('app')
);